import { defHttp } from '@/utils/http/axios';
import { ItemBannerApiResult, ItemBannerInsertOrUpdateForm } from './model/ItemBannerModel';

enum Api {
  REST = '/api/v1/item-banners',
}

/**
 * 数据表注释-分页列表
 */
export const listItemBannerApi = (queryForm: any) => {
  // 选择的是日期，补全时分秒部分
  if (queryForm.beginAt) {
    queryForm.beginAt += ' 00:00:00';
  }

  if (queryForm.endAt) {
    queryForm.endAt += ' 23:59:59';
  }

  return defHttp.get<ItemBannerApiResult[]>({
    url: Api.REST,
    params: queryForm,
  });
};

/**
 * 数据表注释-详情
 */
export const retrieveItemBannerApi = (id: string) => {
  return defHttp.get<ItemBannerApiResult>({
    url: `${Api.REST}/${id}`,
  });
};

/**
 * 数据表注释-新增
 */
export const insertItemBannerApi = (insertForm: ItemBannerInsertOrUpdateForm) => {
  return defHttp.post<void>({
    url: Api.REST,
    params: insertForm,
  });
};

/**
 * 数据表注释-编辑
 */
export const updateItemBannerApi = (id: string, updateForm: ItemBannerInsertOrUpdateForm) => {
  return defHttp.put<void>({
    url: `${Api.REST}/${id}`,
    params: updateForm,
  });
};

/**
 * 数据表注释-删除
 */
export const deleteItemBannerApi = (ids: string[]) => {
  return defHttp.delete<void>({
    url: Api.REST,
    params: {
      ids: ids,
    },
  });
};
